package com.sunclouder.cactus.common.model;


import io.swagger.v3.oas.annotations.media.Schema;

import java.io.Serializable;
import java.util.List;
import javax.validation.constraints.NotNull;

public class PageInfo<T> implements Serializable {
    @Schema(description = "数据列表")
    private @NotNull List<T> records;
    @Schema(description = "总记录数")
    private @NotNull long total;
    @Schema(description = "每页条数")
    private @NotNull int pageSize;
    @Schema(description = "页码")
    private @NotNull long pageNum;
    @Schema(description = "总页数")
    private @NotNull long totalPages;

    public List<T> getRecords() {
        return this.records;
    }

    public long getTotal() {
        return this.total;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public long getPageNum() {
        return this.pageNum;
    }

    public long getTotalPages() {
        return this.totalPages;
    }

    public void setRecords(final List<T> records) {
        this.records = records;
    }

    public void setTotal(final long total) {
        this.total = total;
    }

    public void setPageSize(final int pageSize) {
        this.pageSize = pageSize;
    }

    public void setPageNum(final long pageNum) {
        this.pageNum = pageNum;
    }

    public void setTotalPages(final long totalPages) {
        this.totalPages = totalPages;
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof PageInfo)) {
            return false;
        } else {
            PageInfo<?> other = (PageInfo) o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getTotal() != other.getTotal()) {
                return false;
            } else if (this.getPageSize() != other.getPageSize()) {
                return false;
            } else if (this.getPageNum() != other.getPageNum()) {
                return false;
            } else if (this.getTotalPages() != other.getTotalPages()) {
                return false;
            } else {
                Object this$records = this.getRecords();
                Object other$records = other.getRecords();
                if (this$records == null) {
                    if (other$records != null) {
                        return false;
                    }
                } else if (!this$records.equals(other$records)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof PageInfo;
    }

    public int hashCode() {
        int result = 1;
        long $total = this.getTotal();
        result = result * 59 + (int) ($total >>> 32 ^ $total);
        result = result * 59 + this.getPageSize();
        long $pageNum = this.getPageNum();
        result = result * 59 + (int) ($pageNum >>> 32 ^ $pageNum);
        long $totalPages = this.getTotalPages();
        result = result * 59 + (int) ($totalPages >>> 32 ^ $totalPages);
        Object $records = this.getRecords();
        result = result * 59 + ($records == null ? 43 : $records.hashCode());
        return result;
    }

    public String toString() {
        return "PageInfo(records=" + this.getRecords() + ", total=" + this.getTotal() + ", pageSize=" + this.getPageSize() + ", pageNum=" + this.getPageNum() + ", totalPages=" + this.getTotalPages() + ")";
    }

    public PageInfo(final List<T> records, final long total, final int pageSize, final long pageNum, final long totalPages) {
        this.records = records;
        this.total = total;
        this.pageSize = pageSize;
        this.pageNum = pageNum;
        this.totalPages = totalPages;
    }

    public PageInfo() {
    }
}
